package org.hawk.gwt.ppc.introspection;

import java.util.List;

/**
 * Represents java type: either class, interface, enum or annotation.
 * Subtypes are also provide generic types support.
 * 
 * @author alex.bereznevatiy@gmail.com
 *
 */
public interface JavaTypeScope extends JavaScope, JavaParameterizable {
	
	/**
	 * @return <code>true</code> if this type is an interface
	 */
	public boolean isInterface();

	/**
	 * @return <code>true</code> if this type is a class
	 */
	public boolean isClass();
	
	/**
	 * @return <code>true</code> if this type is enum
	 */
	public boolean isEnum();
	
	/**
	 * @return <code>true</code> if this type is annotation
	 */
	public boolean isAnnotation();
	
	/**
	 * @return list of interfaces explicitly extended by this interface or implemented by this class.
	 */
	public List<JavaTypeScope> getInterfaces();

	/**
	 * @return superclass for this type or <code>null</code> if this is {@link Object} type or interface or annotation.
	 */
	public JavaTypeScope getSuperClass();
	
	/**
	 * @return fully qualified name of this type.
	 */
	public String getName();
	
	/**
	 * @return unmodifiable list of declared constructors of this type
	 */
	List<JavaConstructor> getConstructors();
	
	/**
	 * @return unmodifiable list of declared methods of this type
	 */
	List<JavaMethod> getMethods();
	
	/**
	 * List of java fields declared by this type
	 * @return
	 */
	List<JavaField> getFields();

	/** 
	 * @return generic superclass of this type or null if this is interface or object class.
	 */
	JavaTypeScope getGenericSuperclass();

	/**
	 * @return list of generic interfaces for this type
	 */
	List<JavaTypeScope> getGenericInterfaces();
	
	/**
	 * @return list of types that were participated into methods resolving or other operations
	 * related to this type (e.g. were imported in the import section).
	 */
	List<String> getDependingTypes();

	/**
	 * Performs search for the field in this class and its parents.
	 * @param name
	 * @return field with name specified or <code>null</code> if there is no such field.
	 */
	JavaField getField(String name);
	
	/**
	 * @return unmodifiable list of member classes of this class.
	 */
	List<JavaTypeScope> getDeclaredClasses();

	/**
	 * @return <code>true</code> if this type scope represents primitive type
	 */
	boolean isPrimitive();

	/**
	 * @return <code>true</code> if this type scope represents wrapper for primitive type
	 */
	boolean isPrimitiveWrapper();

	/**
	 * Checks whenever this type is assignable from other one.
	 * Note that this method is not works for primitives.
	 * @param from
	 * @return <code>true</code> if this type is assignable from other type.
	 */
	boolean isAssignableFrom(JavaTypeScope from);
}
